﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using _MetalSlug.Mementoes;

namespace _MetalSlug.Mission
{
    public class MyMap : VisibleGameEntity
    {
        Texture2D Texture;

        public MyMap(string texture,Vector2 size)
        {
            TopLeft = Vector2.Zero;
            Size = size;
            Texture = GameUtil.LoadTexture(texture);
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            Vector2 newPos = TopLeft - new Vector2(GameUtil.GamePivot.PivotPoint,0);
            spriteBatch.Draw(Texture, new Rectangle((int)newPos.X, (int)newPos.Y, (int)Size.X, (int)Size.Y), Color.White);
        }

        public bool CheckMove(Vector2 newPos)
        {
            if (newPos.X >= 0 && newPos.X <= Size.X - GameUtil.ScreenSize.X)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        private Vector2 moveMap(KeyboardState keyBoardState, Vector2 ufo, int speed)
        {
            if (keyBoardState.IsKeyDown(Keys.A))
            {
                ufo.X -= speed;
            }

            if (keyBoardState.IsKeyDown(Keys.D))
            {
                ufo.X += speed;
            }
            return ufo;
        }

        public void RestoreMemento(IMemento OldMemento)
        {
            MapMemento MyMemento = (MapMemento)OldMemento;
            TopLeft = MyMemento.TopLeft;
        }
    }

}
